package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2023-05-20
 * Time: 19:43
 */
class Shape{

    public void draw(){
        System.out.println("画图形");
    }
}

class Rect extends Shape{
    @Override
    public void draw() {
        System.out.println("画矩形");
    }
}

class Cycle extends Shape{
    @Override
    public void draw() {
        System.out.println("画圆");
    }
}

class Triangle extends Shape{
    @Override
    public void draw() {
        System.out.println("画三角形");
    }
}

class Flower extends Shape{
    @Override
    public void draw() {
        System.out.println("画❀");
    }
}

public class TestDemo {

    public static void drawShapes(){
        Shape[] shapes = {new Cycle(), new Rect(), new Flower()};

        /*Shape[] shapes = new Shape[3];
        shapes[0] = new Cycle();
        shapes[1] = new Rect();
        shapes[2] = new Flower();*/

        for (Shape s : shapes) {
            s.draw();
        }

    }

    public static void drawMap(Shape shape){
        shape.draw();
    }

    public static void main(String[] args) {
        Rect rect = new Rect();
        drawMap(rect);

        drawMap(new Cycle());
        drawMap(new Triangle());

        drawMap(new Flower());
    }

    public static void main1(String[] args) {
        Shape shape = new Rect();
        shape.draw();

        Shape shape2 = new Cycle();
        shape2.draw();

        Shape shape3 = new Triangle();
        shape3.draw();
    }
}
